/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import entities.InforCompany;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author hungpm_b01223
 */
public class getInfoCompany {
    ConnectDB myConn=new ConnectDB();
    Connection conn;
    public List<InforCompany> getInfoCompany(String user){
        List<InforCompany> list=new ArrayList<InforCompany>();
        try {
            conn=myConn.getConnect();
            String qr="select * from InforCompany,NhaTuyenDung where Id=(select id from userName where account='"+user+"') AND InforCompany.InforID=NhaTuyenDung.InforID";
            Statement stmt  = conn.createStatement();
            ResultSet rs = stmt.executeQuery(qr);
            while(rs.next()){   
                InforCompany ifc=new InforCompany();
                ifc.setCompanyID(rs.getInt(1));
                ifc.setCompanyName(rs.getString(2));
                ifc.setCompanyOverview(rs.getString(3));
                ifc.setCompanyAddress(rs.getString(4));
                ifc.setCompanyWebsite(rs.getString(5)); 
                list.add(ifc);
            }
        } catch (Exception e) {
        }
        return  list;
    }
    public int layIdCom(String user){
        int id=0;
        String qr="select CompanyID from NhaTuyenDung where id=(select id from userName where account='"+user+"')";
        try {
            conn=myConn.getConnect();
            Statement stmt  = conn.createStatement();
            ResultSet rs = stmt.executeQuery(qr);
            while(rs.next()){
                id=rs.getInt(1);
            }
        } catch (Exception e) {
        }
        return id;
    }
}
